package com.yunfeisoft.business.model;

import com.yunfeisoft.base.model.Attachment;
import com.yunfeisoft.common.base.BaseModel;
import com.yunfeisoft.common.sql.record.TransientField;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.List;

/**
 * @Auther: r.cheng
 * @Date: 2020/4/1 10:15
 * @Description: 老人入院审批结果
 * @Version: 1.0
 */
@Entity
@Table(name = "tt_elder_approval_result")
public class ElderApprovalResult extends BaseModel implements Serializable {
    /**
     * Field serialVersionUID: 序列号
     */
    private static final long serialVersionUID = 1L;

    /**
     * 老人Id
     */
    @Column
    private String elderId;

    /**
     * 审批状态
     */
    @Column
    private Integer status;

    /**
     * 审批意见
     */
    @Column
    private String content;

    /**
     * 审批人名称
     */
    @TransientField
    private String username;

    private List<Attachment> attachmentList;

    public List<Attachment> getAttachmentList() {
        return attachmentList;
    }

    public void setAttachmentList(List<Attachment> attachmentList) {
        this.attachmentList = attachmentList;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getElderId() {
        return elderId;
    }

    public void setElderId(String elderId) {
        this.elderId = elderId;
    }

    public Integer getStatus() {
        return status;
    }

    /**
     * 获取对应的状态码中文简称
     * @return
     */
    public String getStatusStr() {
        return ApprovalStatusEnum.valueOf(this.status);
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    /**
     * 老人入院流程审批状态枚举
     */
    public enum ApprovalStatusEnum {
        ACCEPT(1, "审批通过"),
        REJECT(2, "审批拒绝");

        private int value;

        private String label;

        private ApprovalStatusEnum(int value, String label) {
            this.value = value;
            this.label = label;
        }

        public int getValue() {
            return value;
        }

        public String getLabel() {
            return label;
        }

        public static String valueOf(Integer value) {
            if (value == null) {
                return null;
            }
            ApprovalStatusEnum[] values = ApprovalStatusEnum.values();
            for (ApprovalStatusEnum loop : values) {
                if (value == loop.getValue()) {
                    return loop.getLabel();
                }
            }
            return null;
        }

    }
}
